<template>
	<div class="alarmConfiguration zy-content">
		<search :columns="searchData" @getSearch="getSearch(arguments)" key="search"></search>
		<div class="alarmConfiguration">
			<moldPage ref="moldPage" :isAll="true" :title="$t('common.listInformation')"></moldPage>
		</div>
	</div>
</template>

<script>
import search from '@/components/curd/searchList.vue';
import moldPage from './modules/moldPage.vue';
export default {
	name: 'moldLedger', //工装定义
	components: { search, moldPage },
	data() {
		return {
			searchData: [
				{
					title: '工装名称',
					key: 'equipName',
				},
				{
					title: '工装编号',
					key: 'equipCode',
				},
				{
					title: '工装类型',
					key: 'moldModel',
				},
				{
					title: '资产编号',
					key: 'assetCode',
				},
				{
					title: '工装等级',
					key: 'moldGrade',
					type: 'select',
					dicData: [
						{ label: 'A', value: 'A' },
						{ label: 'B', value: 'B' },
						{ label: 'C', value: 'C' },
					],
				},
				{
					title: '状态',
					key: 'moldStateList',
					type: 'select',
					multiple: true,
					dicUrl: '/dms/faultCategory/dictList?name=工装状态',
					params: {
						label: 'value',
						value: 'value',
					},
				},
				{
					title: '功能位置',
					key: 'functionLocation',
					type: 'cascader',
					dicUrl: '/basic/organization/findListByToken?level=0',
					params: {
						label: 'name',
						value: 'code',
						children: 'children',
					},
				},
			],
			searchParams: {},
		};
	},
	mounted() {
		this.$nextTick(() => {
			this.$refs.moldPage.searchList(this.searchParams);
		});
	},
	watch: {
		// 'searchParams.companyId': {
		// 	handler() {
		// 		this.backupId = null;
		// 		this.$set(this.searchParams, 'backupName', null);
		// 		this.backupList = [];
		// 	},
		// 	deep: true,
		// },
	},
	methods: {
		getSearch(params) {
			this.searchParams = JSON.parse(JSON.stringify(params[0]));
			const { functionLocation, moldStateList } = this.searchParams;
			if (functionLocation && functionLocation.length) {
				this.searchParams.functionLocation = [this.searchParams.functionLocation.at(-1)];
			} else delete this.searchParams.functionLocation;
			if (moldStateList && moldStateList.length == 0) {
				delete this.searchParams.moldStateList;
			}
			this.$refs.moldPage.pageNum = 1;
			this.$refs.moldPage.searchList(this.searchParams);
		},
		reset() {
			this.searchParams = {};
			this.$refs.moldPage.searchList(this.searchParams);
		},
	},
};
</script>

<style scoped lang="scss">
.ivu-input-number {
	width: -webkit-fill-available;
}
</style>